from keras import Input
from keras.layers import Maximum

from log import log
from .base_layer import BaseLayer


class MaximumLayer(BaseLayer):
    def transfer(self, model_list_line: list, inputs: Input, models: list = None):
        outputs = [model.outputs[0] for model in models]
        return Maximum()(outputs)

    def check(self, model_list_line: list, models: list = None) -> bool:
        if models is not None and len(models) <= 1:
            log.error("models传入只能在集成部分且传入>1个模型")
            raise RuntimeError("models传入只能在集成部分且传入>1个模型")
        return True
